import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:news_demo/Pojo/Home_Index_Pojo.dart';
import 'package:news_demo/Pojo/News_Itme_Pojo.dart';
import 'package:news_demo/View/Home/Widget/NewsList.dart';

class Index extends StatefulWidget {
  late Home_Index_Pojo HIP;
  late List<NewsItmePojo>NewsListArray;
  Index({Key? key, required this.HIP,required this.NewsListArray}) : super(key: key);

  @override
  State<Index> createState() => _IndexState(
    HIP: this.HIP,
    NewsListArray: NewsListArray,
  );
}

class _IndexState extends State<Index> {
  late Home_Index_Pojo HIP;
  late List<NewsItmePojo>NewsListArray;
  _IndexState({required this.HIP,required this.NewsListArray});


  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      padding: EdgeInsets.all(1),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment:  MainAxisAlignment.end,
        children: [
          //轮播图的总体
          Container(
            child: Column(
              children: [
                Container(
                  height: 40,
                  width: double.infinity,
                  margin: EdgeInsets.fromLTRB(0, 3.0, 0, 3.0),
                  decoration: BoxDecoration(
                    color: Color.fromRGBO(168, 183, 185, 100),
                    borderRadius: BorderRadius.all(Radius.circular(10)),
                  ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Container(
                        child: Text("今日精选" ,
                          style: TextStyle(
                              fontSize: 20,
                          ),
                        ),
                        margin: EdgeInsets.fromLTRB(10, 0, 0, 0),
                      )
                    ],
                  ),
                ),
                Container(
                    height: 150,
                    width: double.infinity,
                    // color: Colors.blue,
                    child: Swiper(
                      itemCount: HIP.GetImageList.length,
                      itemBuilder: (context,index){
                        return Image.network(HIP.GetImageList[index]);
                      },
                    )
                ),
              ],
            ),
          ),
          //消息资讯
          NewsList(ListArray:NewsListArray),
        ],
      ),
    );
  }
}
